using System.Data;
using System.Data.SqlClient;
using VanTaiProperty;
namespace VanTaiData
{
    public class clsTMTypesOfBusinessesController
    {
        private clsConnect cls = new clsConnect();
        private DataTable dt;
        #region[Get-Data]
        public DataTable BindGirdTMTypesOfBusinesses()
        {
            return cls.BindGridData("sp_TMTypesOfBusinesses");
        }
        public DataTable BindGirdTMTypesOfBusinesses_Detail_Edit(int id)
        {
            return cls.LayDuLieuParameter("sp_TMTypesOfBusinesses_Detail_Edit", "@TypesOfBusinesses_ID", id);
        }
        #endregion

        #region[Insert-Update-Delete]
        public bool InsertTMTypesOfBusinesses(clsTMTypesOfBusinessesProperty data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@TypesOfBusinesses_Alias", data.TypesOfBusinesses_Alias);
            cls.AddParameter("@TypesOfBusinesses_Name", data.TypesOfBusinesses_Name);
            cls.AddParameter("@TypesOfBusinesses_Note", data.TypesOfBusinesses_Note);
            cls.ExecuteNonQuery("sp_TMTypesOfBusinesses_Insert");
            return true;
        }
        public bool UpdateTMTypesOfBusinesses(clsTMTypesOfBusinessesProperty data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@TypesOfBusinesses_ID", data.TypesOfBusinesses_ID);
            cls.AddParameter("@TypesOfBusinesses_Alias", data.TypesOfBusinesses_Alias);
            cls.AddParameter("@TypesOfBusinesses_Name", data.TypesOfBusinesses_Name);
            cls.AddParameter("@TypesOfBusinesses_Note", data.TypesOfBusinesses_Note);
            cls.ExecuteNonQuery("sp_TMTypesOfBusinesses_Update");
            return true;
        }
        public bool DeleteTMTypesOfBusinesses(int id)
        {
            cls.Delete("sp_TMTypesOfBusinesses_Delete", "@TypesOfBusinesses_ID", id);
            return true;
        }
        public bool TMCommandTransferOrder_Check_Delete_TMSalesReport(int id)
        {
            dt = cls.LayDuLieuParameter("sp_TMTypesOfBusinesses_Check_Delete_TMCustomer", "@Id", id);
            if (dt.Rows.Count > 0)
                return true;
            return false;
        }
        #endregion

        #region[Search]
        public DataTable Search(string keywords)
        {
            return cls.Search("sp_TMTypesOfBusinesses_Search", "@KEYWORDS", keywords);
        }
        #endregion
    }
}